package com.kefu.chat.service;

import cn.hutool.core.util.StrUtil;
import com.kefu.chat.mapper.ChatFaqGroupDocRelMapper;
import com.kefu.chat.model.ChatFaqGroupDocRel;
import com.kefu.chat.vo.ChatFaqGroupDocInsertVo;
import com.kefu.chat.vo.ChatFaqGroupDocRelSearchVo;
import com.kefu.common.service.AbstractKefuService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ChatFaqGroupDocRelService extends AbstractKefuService<ChatFaqGroupDocRel> {
    @Resource
    private ChatFaqGroupDocRelMapper chatFaqGroupDocRelMapper;

    public String addDoc(ChatFaqGroupDocInsertVo chatFaqGroupDOcVo) {
        List<ChatFaqGroupDocRel> list = chatFaqGroupDOcVo.getChatFaqGroupDocRelList();
        list.forEach(chatFaqGroupDocRel -> {
            if (StrUtil.isBlank(chatFaqGroupDocRel.getId())) {
                chatFaqGroupDocRelMapper.insert(chatFaqGroupDocRel);
            }
        });
        return "1";
    }

    public List<ChatFaqGroupDocRel> getGroupDocList(ChatFaqGroupDocRelSearchVo search) {
        List<ChatFaqGroupDocRel> list = chatFaqGroupDocRelMapper.selectList(search.lambdaQuery());
        return list;
    }
}
